Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

160
Visualizações
Need to get each "link" entry from nested json using js

There is a json code. Consisting by type: {"123":{...},"321":{...}} In it, you need to get "links" from each entry. I couldn't understand this note, please help me.

{
"3782474584475521065": {
    "listingid": "3782474584475521065",
    "price": 16,
    "asset": {
        "currency": 0,
        "appid": 730,
        "contextid": "2",
        "id": "25996697315",
        "amount": "1",
        "market_actions": [
            {
                "link": "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M%listingid%A%assetid%D2354938592644984102",
                "name": "Осмотреть в игре…"
            }
        ]
    }
},
"3782474584475520325": {
    "listingid": "3782474584475520325",
    "price": 16,
    "asset": {
        "currency": 0,
        "appid": 730,
        "contextid": "2",
        "id": "25996698023",
        "amount": "1",
        "market_actions": [
            {
                "link": "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M%listingid%A%assetid%D9866835690490179400",
                "name": "Осмотреть в игре…"
            }
        ]
    }
}

}

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

If I understood your question correctly, you need to extract the links from the json text. This is a solution:

const a = {
  "3782474584475521065": {
    listingid: "3782474584475521065",
    price: 16,
    asset: {
      currency: 0,
      appid: 730,
      contextid: "2",
      id: "25996697315",
      amount: "1",
      market_actions: [
        {
          link: "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M%listingid%A%assetid%D2354938592644984102",
          name: "Осмотреть в игре…",
        },
      ],
    },
  },
  "3782474584475520325": {
    listingid: "3782474584475520325",
    price: 16,
    asset: {
      currency: 0,
      appid: 730,
      contextid: "2",
      id: "25996698023",
      amount: "1",
      market_actions: [
        {
          link: "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M%listingid%A%assetid%D9866835690490179400",
          name: "Осмотреть в игре…",
        },
      ],
    },
  },
};

// get links from a
const links = Object.values(a).map(({ asset }) => {
  const { market_actions } = asset;
  const { link } = market_actions[0];
  return link;
});

console.log(links);

This simply iterates through the object's values and accesses the link values through object extraction.

about 4 years ago · Juan Pablo Isaza Relatório

0

Return an array of objects {id:link}

const data = {
  "3782474584475521065": {
    "listingid": "3782474584475521065",
    "price": 16,
    "asset": {
      "currency": 0,
      "appid": 730,
      "contextid": "2",
      "id": "25996697315",
      "amount": "1",
      "market_actions": [
          {
              "link": "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M%listingid%A%assetid%D2354938592644984102",
              "name": "Осмотреть в игре…"
          }
      ]
    }
  },
  "3782474584475520325": {
    "listingid": "3782474584475520325",
    "price": 16,
    "asset": {
      "currency": 0,
      "appid": 730,
      "contextid": "2",
      "id": "25996698023",
      "amount": "1",
      "market_actions": [
          {
              "link": "steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M%listingid%A%assetid%D9866835690490179400",
              "name": "Осмотреть в игре…"
          }
      ]
    }
  }
}
const result = Object.entries(data).map(([key, {asset, ...rest}]) => ({[key]: asset.market_actions[0].link}))
console.log(result)

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda